using System.Collections;
using System.Collections.Generic;
using PixelCrushers.DialogueSystem;
using UnityEngine;
using XFGameFramework;
using XFGameFramework.SkillSystem;

public class BasicAttack : TakeDamageBase
{
    public int theSkillId = 10000;
    Module module = ModuleManager.GetModule("MainModule");
    private PlayerController playerController => module.LoadController<PlayerController>();
    SkillController skillController => module.LoadController<SkillController>();
    GameSaveController gameSaveController => module.LoadController<GameSaveController>();
    private SkillConfig SkillConfig => XFABManager.AssetBundleManager.LoadAsset<SkillConfig>(module.ModuleName, "SkillConfig");

    // private SkillConfig basicAttackConfig = 

    //初始化

    public BasicAttack(RolesModel creator, RolesModel target, int Id) : base(creator, target, Id)
    {

    }


    public override void ApplyAction()
    {
        base.ApplyAction();
        if (target == null)
        {
            Debug.LogError("没有目标");
        }
        if (creator == null)
        {
            Debug.LogError("没有创建者");
        }
        List<int> skillList = skillController.GetSkillList(creator);
        
        foreach (int skillId in skillList)
        {
            if (skillId == theSkillId)
            {
                Debug.Log("角色技能列表找到技能ID" + theSkillId);
                skillController.skillCDUP(creator, skillId, SkillConfig.GetSkillInfo(skillId).cooling_rounds);
                //CD增加，禁用技能通过禁用UI实现
                List<int> skillCd = playerController.GetSkillCd();
                break;
                
            }
        }
        //CD增加，禁用技能通过禁用UI实现

        // if (!creator.skillsID.Contains(theSkillId))
        // {
        //     Debug.Log("角色技能列表没有找到技能" + theSkillId);
        // }
        BasicAttack basicAttack = new BasicAttack(creator, target, theSkillId);
        basicAttack.ComputeDamage();

    }
}
